<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Document</title>
    <link rel="stylesheet" href="css/sai-theme.css">
</head>
<body>
    <div class="container">
        <section class="panel panel-default col-md-6 col-sm-6">
            <div class="panel-heading">输入框</div>
            <div class="panel-bady">
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="inputEmain" class="">用户名</label>

                        <div class="col-md-10 col-sm-10">
                            <input type="text" class="form-control" id="inputusername" placeholder="请输入用户名" required>
                            <div class="tooltip input-tooltip-inline">
                                <div class="tooltip-inner label-danger hide">

                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group ">
                        <label for="password" class="col-md-2 col-sm-2 control-label">密码</label>
        
                        <div class="col-md-10 col-sm-10">
                            <input type="password" class="form-control" id="password" placeholder="请输入密码" required>
                            <div class="tooltip input-tooltip-inline">
                                <div class="tooltip-inner label-danger hide">
                                        
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group ">
                        <label for="password" class="col-md-2 col-sm-2 control-label">再次确认密码</label>
                        <div class="col-md-10 col-sm-10">
                            <input type="password" class="form-control" id="password1" placeholder="请输入密码" required>
                            <div class="tooltip input-tooltip-inline">
                                <div class="tooltip-inner label-danger hide">
                                        
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-2 col-sm-2 col-xs-2 col-sm-offset-2">
                            <button type="submit" class="btn btn-default">登录</button>
                        </div>
                        <div class="col-md-2 col-sm-2 col-xs-2">
                            <button type="button" id="btnregister" class="btn btn-primary">注册</button>
                        </div>
        
                    </div>
        
                </form>
            </div>
        </section>
    </div>
    

    <!-- /container -->


<script src="js/jquery/jquery-1.11.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="lib/bmob.js"></script>
<script>
$(function(){
    bmob.initialize("9380b8fef6adad915286c53f0e0c3580","0a1523cbc7b6339582143a793c8c4cee");

    $('#btnregister').click(function(){
        var $userID = $('#inputusername');
        var $userPwd = $("#password");
        var $userPwdcheck = $("#password1");

        if($userID.val().leang == 0 )
        {
            $userID.parent().removeClass("has-success").addClass("has-error");
            $userID.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
            $userID.parent().find(".tooltip-inner").text("用户名不能为空");
            $userID.focus();
            return; 
        }
        else if($userID.val().leang > 10)
        {
            $userID.parent().removeClass("has-success").addClass("has-error");
                $userID.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
                $userID.parent().find(".tooltip-inner").text("用户名不能超过10个字符");
                $userID.focus();
                return;
        }

        if($userID.val().leang == 0 )

        {
            $userPwd.parent().removeClass("has-success").addClass("has-error");
                $userPwd.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
                $userPwd.parent().find(".tooltip-inner").text("密码不能为空");
                $userPwd.focus();
                return;
            }
            else if($userPwd.val().length > 10)
            {
                $userPwd.parent().removeClass("has-success").addClass("has-error");
                $userPwd.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
                $userPwd.parent().find(".tooltip-inner").text("密码不能超过10个字符");
                $userPwd.focus();
                return;
            }
 	
 	
 			if($userPwdcheck.val().length == 0  )
            {
                $userPwdcheck.parent().removeClass("has-success").addClass("has-error");
            $userPwdcheck.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
                $userPwdcheck.parent().find(".tooltip-inner").text("密码不能为空");
                $userPwdcheck.focus();
                return;
            }
            else if($userPwdcheck.val().length > 10)
            {
                $userPwdcheck.parent().removeClass("has-success").addClass("has-error");
                $userPwdcheck.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
                $userPwdcheck.parent().find(".tooltip-inner").text("密码不能超过10个字符");
                $userPwdcheck.focus();
                return;
            }
            else if($userPwdcheck.val() != $userPwd.val())
            {
                           $userPwdcheck.parent().removeClass("has-success").addClass("has-error");
                $userPwdcheck.parent().find(".tooltip-inner").removeClass("label-success").removeClass("hide").addClass("label-danger");
                $userPwdcheck.parent().find(".tooltip-inner").text("两次输入密码不一致");
                $userPwdcheck.focus();
                return;
            }


		var user = new Bmob.User();
		user.set("username", $userID.val());
		user.set("password", $userPwd.val());

		// other fields can be set just like with Bmob.Object

		user.signUp(null, {
		  success: function(user) {
		    // Hooray! Let them use the app now.
		    alert(user);
		  },
		  error: function(user, error) {
		    // Show the error message somewhere and let the user try again.
		    alert("Error: " + error.code + " " + error.message);
		  }
		});
 	
 	
 	});
 	
 	
 	
 	function check（）
 	{
 	
 	}
 	
 	
 	
 });


</script>
</body>
</html>